import { Token } from '../types/data'
const TOKEN_KEY = 'token'

// 获取token

const getToken = (): Token =>
  JSON.parse(
    localStorage.getItem(TOKEN_KEY) || '{"token":"","refresh_token":"" }'
  )
//设置token

const setToken = (data: Token) =>
  localStorage.setItem(TOKEN_KEY, JSON.stringify(data))
//移除token

const removeToken = () => localStorage.removeItem(TOKEN_KEY)
// 判断是否登录

const isAuth = () => !!getToken()
export { getToken, setToken, removeToken, isAuth }
